package com.hubu.mapper;
import com.hubu.pojo.administratorUser;
import com.hubu.pojo.student_Information;
import com.hubu.pojo.teacher_Information;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface administratorUserMapper {

    @Select("SELECT 管理员账号 AS username, 管理员密码 AS password " +
            "FROM 管理员账号表 " +
            "WHERE 管理员账号 = #{username} AND 管理员密码 = #{password}")
    administratorUser select(@Param("username") String username, @Param("password") String password);

    @Select("select 管理员账号 AS username from 管理员账号表 where 管理员账号 = #{username}")
    administratorUser selectByUsername(String username);

    @Insert("insert into 管理员账号表 values(#{username},#{password})")
    void add(administratorUser administratorUser);

    @Select("select 教师号 AS id,教师姓名 AS name,教师性别 AS gender,教师年龄 AS age,职称 AS office,电话 AS phone  from 教师表")
    List<teacher_Information> selectAllTeacher();

    @Select("select 学号 AS id,姓名 AS name,性别 AS gender,年龄 AS age,已修学分 AS credit,班级号 AS Class_id  from 学生表")
    List<student_Information> selectAllStudent();

    @Insert("insert into 教师表  VALUES (#{id},#{name},#{gender},#{age},#{office},#{phone})")
    void insertTeacher(teacher_Information teacherInformation);

    @Insert("insert into 学生表(学号, 姓名, 性别, 年龄, 班级号) VALUES (#{id},#{name},#{gender},#{age},#{class_id})")
    void insertStudent(student_Information studentInformation);

    @Update("update 学生表 set 姓名=#{name},性别=#{gender},年龄=#{age},已修学分=#{credit},班级号=#{class_id} where 学号=#{id}")
    void updateByStudentId(student_Information studentInformation);

    @Update("update 教师表 set 教师姓名=#{name},教师性别=#{gender},教师年龄=#{age},职称=#{office},电话=#{phone} where 教师号=#{id}")
    void updateByTeacherId(teacher_Information teacherInformation);

    @Delete("delete from`学生表`where`学号`=#{id}")
    void deleteStudentById(String id);

    @Delete("delete from`教师表`where`教师号`=#{id}")
    void deleteTeacherById(String id);

}